package com.situ.springboot.controller;

import com.situ.springboot.pojo.vo.CountCustomidVo;
import com.situ.springboot.pojo.vo.CountServiceidVo;
import com.situ.springboot.service.RecordService;
import com.situ.springboot.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/echarts")
public class EChartsController {
    @Autowired
    private RecordService recordService;

    @RequestMapping("/toECharts")
    public String toECharts() {
        return "/echart/echarts";
    }

    @RequestMapping("/selectByCustomIdCount")
    @ResponseBody
    public Result selectByCustomIdCount() {
        List<CountCustomidVo> list = recordService.selectByCustomIdCount();
        return Result.ok(list);
    }

    @RequestMapping("/selectByServiceIdCount")
    @ResponseBody
    public Result selectByServiceIdCount() {
        List<CountServiceidVo> list = recordService.selectByServiceIdCount();
        return Result.ok(list);
    }

    @RequestMapping("/generateuser") //生成表
    public  String selectCount(Model model){
        List<CountCustomidVo> customidVos = recordService.selectByCustomIdCount();
        model.addAttribute("customidVos",customidVos);
        List<CountServiceidVo> serviceidVos = recordService.selectByServiceIdCount();
        model.addAttribute("serviceidVos",serviceidVos);
        return "/echart/echartstable";
    }
//    public String selectuser(Model model){
//        List<consumpvo> consumpvos=consumpService.selectname();
//        model.addAttribute("consumpvos",consumpvos);
//        List<coursevo> coursevos=consumpService.selectcourse();
//        model.addAttribute("coursevo",coursevos);
//        return "/echartstable";
//    }
}
